#!/usr/local/bin/python

# example usage - ./test.py *.wav or python test.py *.wav

import copy
from pycdp import *

if __name__ == "__main__":  # python convention, but i think you can leave it out...
    mono = cdp.housekeep.chans(4)
    norm = cdp.modify.loudness(3)

    #dc = cdp.housekeep.extract(4)
    #dc.shift = 0.2
    tt = cdp.housekeep.extract(3)
    tt.g = 0.2
    tt.s = 15 

    dc = cdp.filter.lohi(1)
    dc.set_value("stop-band", 22050)
    dc.set_value("pass-band", 20)
    dc.set_value("attenuation", -12)
    
    dv = cdp.envel.dovetail(2)
    dv.infadedur = 1024
    dv.outfadedur = 1024
    dv.t = 1 # set time unit to samples

    dp = cdp.distort.pitch()
    dp.octvary = 8
    dp.c = 64

    dp2 = cdp.distort.pitch()
    dp2.octvary = 4
    dp2.c = 64 

    cut = cdp.sfedit.cut(1)
    cut.start = 0
    cut.end = 60

    rv = cdp.modify.revecho(3)

    ps = cdp.modify.brassage(1)
    ps.pitchshift = 8

    ts = cdp.modify.brassage(2)
    ts.velocity = 0.5

    ts2 = cdp.modify.brassage(2)
    ts2.velocity = 1.85

    reverse = cdp.modify.radical(1)

    chain = []
    chain.append(mono)
    chain.append(dc)
    #chain.append(ts)
    chain.append(rv)
    chain.append(mono)
    chain.append(dp)
    chain.append(rv)
    chain.append(reverse)
    chain.append(mono)
    #chain.append(ps)
    chain.append(ts2)
    chain.append(dc)
    chain.append(norm)
    chain.append(tt)
    chain.append(dv)

    output_files = cdp.run_chain(chain, sys.argv[1:], False)

    print(output_files) # debug!
